﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Incident_Manager_PUCP
{
    public partial class frmConsultaTickets : Form
    {


        public frmConsultaTickets()
        {
            InitializeComponent();
        
        
        }

        private void lblBienvenido_Click(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void btnSalir_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            //List<Cliente> lista_temp = new List<Cliente>();
            //lista_temp = frmRegistrarCliente.lista;

            GestorTicket gestorTicket = GestorTicket.ObtenerInstancia();
            string codigo = textBox2.Text;
            if (codigo.Trim().Equals(string.Empty))
            {
                codigo = null;
            }
            var tickets = (from t in gestorTicket.listaTickets
                          where t.getCodigo().Contains(codigo ?? t.getCodigo())
                          select t).ToList();

            tickets.ForEach(t =>
                                {
                                    int x = dataGridView1.Rows.Add();
                                    dataGridView1.Rows[x].Cells[0].Value = t.getCodigo();
                                    dataGridView1.Rows[x].Cells[1].Value = t.getTitulo();
                                    dataGridView1.Rows[x].Cells[2].Value = t.getTipo();
                                    dataGridView1.Rows[x].Cells[3].Value = t.getPrioridad();
                                });
            dataGridView1.ClearSelection();
        }
    }
}
